package pc15;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class ExJdbcTest {

	public static void main(String[] args) throws Exception {
		String driver="oracle.jdbc.driver.OracleDriver";
		String url="jdbc:oracle:thin:@localhost:1521:xe";
		String id="scott", pass="TIGER";
		String sql,result="";
		
		Class.forName(driver);
		System.out.println("Driver load...");
		
		Connection con=DriverManager.getConnection(url,id,pass);
		System.out.println("DB connect...");
		
		Statement st=con.createStatement();
		sql="select ename from emp";
		ResultSet rs=st.executeQuery(sql);
		
		while(rs.next()){
			result += rs.getString(1)+"\t";
		}
		rs.close();
		st.close();
		con.close();
		
		//결과 출력
		System.out.println(result);
		
	}
}
